import { ElMessage } from "element-plus";
import router from "./router";
import { useUserStore } from "./stores/user";

const WHITE_LIST = ['/login',"/404"];
router.beforeEach((to, from, next) => {
  const store = useUserStore();
  if(store.token){
    next()
  }else if( WHITE_LIST.includes(to.path)){
    next()
  }else{
    next('/login')
    ElMessage.error('登录信息失效')
  }
});